package com.haoshuang.zhouzhoubang.ui.page.settled.contract

import android.content.Context
import android.os.Bundle
import com.haoshuang.zhouzhoubang.config.URLConstants
import com.haoshuang.zhouzhoubang.databinding.ActivitySignContractBinding
import com.haoshuang.zhouzhoubang.ui.page.settled.autograph.AutographActivity
import com.haoshuang.zhouzhoubang.ui.page.settled.collaborationcosts.CollaborationCostsActivity
import com.haoshuang.zhouzhoubang.utils.WebSettingsUtils
import com.lnkj.jialubao.utils.AccountUtils
import com.mufeng.libs.base.BaseVMActivity
import com.mufeng.libs.utils.startPage
import com.mufeng.libs.utils.startPageForResult
import com.mufeng.libs.utils.toast
import com.mufeng.libs.utils.view.click


/**
 *  签署合同
 */
class SignContractActivity : BaseVMActivity<SignContractViewModel, ActivitySignContractBinding>() {

    companion object {
        fun launch(context: Context) {
            context.startPage<SignContractActivity>()
        }
    }

    override fun initView(savedInstanceState: Bundle?) {

        binding.titleBar.title = "签署合同"
        binding.titleBar.leftImageView().click { finish() }

        WebSettingsUtils.setWebSettings(mActivity, binding.webView)
        binding.webView.loadUrl("${URLConstants.baseUrl}index/index/agreement?id=27")

        binding.tvSign.click {
            startPageForResult<AutographActivity>{code, data ->
                if(code == 200){
                    val team = AccountUtils.user?.team
                    if (team?.is_pay_team_deposit == 1) {
                        // 进入费用页面
                        startPage<CollaborationCostsActivity>()
                    }
                    finish()
                }
            }
        }

    }

    override fun initData() {

    }

    override fun startObserve() {

    }

}